import request from "@/utils/request";

// 查询订单列表
export function listSorder(query) {
    return request({
        url: "/biz/sorder/list",
        method: "get",
        params: query
    });
}

// 查询订单详细
export function getSorder(id) {
    return request({
        url: "/biz/sorder/" + id,
        method: "get"
    });
}

// 新增订单
export function addSorder(data) {
    return request({
        url: "/biz/sorder",
        method: "post",
        data: data
    });
}

// 修改订单
export function updateSorder(data) {
    return request({
        url: "/biz/sorder",
        method: "put",
        data: data
    });
}

// 删除订单
export function delSorder(id) {
    return request({
        url: "/biz/sorder/" + id,
        method: "delete"
    });
}

// 导出订单
export function exportSorder(query) {
    // if (window.navigator.msSaveBlob) {  // IE以及IE内核的浏览器
    //     try {
    //       window.navigator.msSaveBlob(res, fileName)  // res为接口返回数据，这里请求的时候已经处理了，如果没处理需要在此之前自行处理var data = new Blob([res.data]) 注意这里需要是数组形式的,fileName就是下载之后的文件名
    //       // window.navigator.msSaveOrOpenBlob(res, fileName);  //此方法类似上面的方法，区别可自行百度
    //     } catch (e) {
    //       console.log(e)
    //     }
    //   } else {
    //     let link = document.createElement('a')
    //     link.href = process.env.VUE_APP_BASE_API + '/biz/sorder/export?orderIdList=' + query
    //     // let url = window.URL.createObjectURL(new Blob([res]))
    //     link.style.display = 'none'
    //     document.body.appendChild(link)
    //     link.click()
    //     document.body.removeChild(link) // 下载完成移除元素
    //     window.URL.revokeObjectURL(url) // 释放掉blob对象
    //   }
    return request({
        url: "/biz/sorder/export",
        method: "get",
        params: query
    });
}

// 导入订单
export function importOrder(data) {
    return request({
        url: "/after_sale/poiImport",
        method: "post",
        data: data
    });
}

// 确认导入订单
export function toImportOrder(data) {
    return request({
        url: "/after_sale/saveOuterSorder",
        method: "post",
        data: data
    });
}

export function submitWuliu(data) {
    return request({
        url: "/web/submitWuliu",
        method: "post",
        data: data
    });
}

export function comfirmget(data) {
    return request({
        url: "/web/comfirmget/" + data,
        method: "get"
    });
}
